/*
 * Circle.cpp
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#include "../../../include/core/shape/Circle.h"
#include <fstream>
#include <iostream>
#include "../../../include/core/shape/Shape.h"
#include <stdlib.h>

vector<Shape*> Circle::get_shapes_from_file(string filename)
{
	vector<double> x_pos;
	vector<double> y_pos;
	vector<double> radius;


	double tmp;

	ifstream input (filename.c_str());
	if(input.good())
	{
		while(!input.eof())
		{
				input >> tmp; x_pos.push_back(tmp);
				input >> tmp; y_pos.push_back(tmp);
				input >> tmp; radius.push_back(tmp);
		}
		input.close();
	}
	else
	{
		cout << "ERROR: with file " << filename << " -> no such file or directory." << endl;
		exit(1);
	}

	vector<Shape*> circles;

	for(unsigned int i=0;i<x_pos.size();i++)
	{
		vector<double> pos (2,0);
		pos [0] = x_pos[i];
		pos [1] = y_pos[i];
		circles.push_back(new Circle(pos,radius[i]));
	}

	return circles;
}

Circle* Circle::convert_from_ellipse(Ellipse* ellipse)
{
	return new Circle(ellipse->get_center(),ellipse->get_radius());
}
